<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Element-ui</title>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">

</head>
<body>
<div id="app">
    <el-button @click="visible = true">Button</el-button>
<!--    弹框 -> 对话框  visible属性: 代表是否显示  -->
    <el-dialog
            :visible.sync="visible"
            title="Hello world"
            width="30%"
            :before-close="handleClose"
    >
        <span>这是一段信息</span>
        <span slot="footer" class="dialog-footer">
            <el-button @click="visible = false">取 消</el-button>
            <el-button type="primary" @click="visible = false">确 定</el-button>
          </span>
<!--        <p>Try Element</p>-->
    </el-dialog>
</div>
</body>
<script src="https://unpkg.com/vue@2/dist/vue.js"></script>
<!-- 引入组件库 -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script>
    new Vue({
        el: '#app',
        data(){
            return {
                visible: false
            }
        },
        methods: {
            handleClose(done){
                console.log(this)  // 调用原生的方法确认框
                this.$confirm("确认关闭?").then(_ => {
                    done();
                }).catch(_ => {

                })
            }
        }
    })
</script>
</html>